#pragma once

#include <iostream>
#include <string>
#include <functional>
#include "Log.hpp"

// typedef std::function<void (int, const std::string &, const uint16_t &, const std::string &)> func_t;
using func_t = std::function<void(int, const std::string &, const uint16_t &, const std::string &)>;

// 该task要以_startRoutine这样的方式给ip:port的客户端提供服务
class Task
{
public:
    int _socketFd;
    std::string _ip;
    uint16_t _port;
    func_t _startRoutine;

public:
    Task() {}
    Task(int sock, const std::string ip, uint16_t port, func_t startRoutine)
        : _socketFd(sock),
          _ip(ip),
          _port(port),
          _startRoutine(startRoutine)
    {
    }
    
    void startProcess(const std::string &threadName)
    {
        _startRoutine(_socketFd, _ip, _port, threadName);
    }
};
